package org.example.factory.abstractFactory;

import org.example.factory.service.Action;

public class ActionDemo {
    private Action jump;
    private Action run;
    private Action sing;

    public ActionDemo(AbstractActionFactory factory) {
        jump = factory.createJumpAction();
        run = factory.createRunAction();
        sing = factory.createSingAction();
    }

    public void performActions() {
        System.out.println("=== 开始表演 ===");
        jump.doAction();
        run.doAction();
        sing.doAction();
        System.out.println("=== 表演结束 ===\n");
    }

    public static void main(String[] args) {
        // 创建运动员动作演示
        AbstractActionFactory athleteFactory = new AthleteActionFactory();
        ActionDemo athlete = new ActionDemo(athleteFactory);
        System.out.println("运动员的动作表现:");
        athlete.performActions();

        // 创建歌手动作演示
        AbstractActionFactory singerFactory = new SingerActionFactory();
        ActionDemo singer = new ActionDemo(singerFactory);
        System.out.println("歌手的动作表现:");
        singer.performActions();

        // 创建普通人动作演示
        AbstractActionFactory normalFactory = new NormalPersonActionFactory();
        ActionDemo normalPerson = new ActionDemo(normalFactory);
        System.out.println("普通人的动作表现:");
        normalPerson.performActions();
    }
}